<template>
	<view class="page">
		<cu-custom bgColor="bg-gradual-red" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">{{title}}</block>
		</cu-custom>

		<view class="loginBox">

			<view class="logoBox animation-slide-bottom" :style="[{animationDelay: (0 + 1)*0.1 + 's'}]">
				<view class="logoBox1">
					<open-data type="userAvatarUrl" class="touxiangImg"></open-data>
				</view>

			</view>

			<view class="loginButton">
				<button class="cu-btn bg-green lg animation-slide-bottom" :style="[{animationDelay: (1 + 1)*0.1 + 's'}]"
					open-type="getUserInfo" @getuserinfo="getuserinfo">
					<text class="cuIcon-weixin"></text>
					&nbsp;微信一键登录</button>
				<!-- <button class="cu-btn  margin-tb-sm lg animation-slide-bottom" :style="[{animationDelay: (2 + 1)*0.1 + 's'}]">手机号登录</button> -->
			</view>

			<view class="bottomBox animation-slide-bottom" :style="[{animationDelay: (4 + 1)*0.1 + 's'}]">

				登录即同意《<view class="xiyi" @click="changeTo('/pages/popup/panel','user_agreement')">用户协议</view>》和 《<view
					class="xiyi" @click="changeTo('/pages/popup/panel','private_agreement')">隐私协议</view> 》
			</view>

		</view>


	</view>

</template>

<script>
	export default {

		data() {
			return {
				msg: "是否绑定手机号？",
				title: "登录",
			}

		},
		onReady: () => {
			//判断是否授权
			console.log("查看师是否授权");
			uni.getSetting({
				success: (res) => {
					console.log(res);
				}
			})



		},
		onShareAppMessage(res) {
			console.log("分享的openid " + this.initCode);
			return {
				title: "乐知课程艺术中心",
				path: '/pages/index/index?userCode=' + this.initCode
			}

		},
		methods: {
		
			/**
			 * 获取授权的信息
			 * @param {Object} e
			 */
			getuserinfo(e) {
				uni.setStorage({
					key: "userInfo",
					data: e.detail.userInfo,
					success: (res) => {
						console.log("授权成功");
						let pages = getCurrentPages();
						let beforePage = pages[pages.length - 2];
						uni.navigateBack({
							delta: 1,
							success: function() {
								beforePage.$vm.reciveAuth(true);
							}
						})
					}
				})

			},
			changeTo(url, type) {
				console.log(url + " : " + type);
				uni.navigateTo({
					url: url + "?type=" + type,
					animationType: 'pop-in'

				});
			}
		}


	}
</script>

<style scoped>
	@import 'login.css';
</style>
